package com.fdw.smartexam_system.system.controller;

import com.fdw.smartexam_system.system.model.StudentAnswer;
import com.fdw.smartexam_system.system.service.StudentAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/answer")
public class StudentAnswerController {

    @Autowired
    private StudentAnswerService studentAnswerService;

    @PostMapping("/submit")
    public ResponseEntity<?> submitAnswer(@RequestBody StudentAnswer answer) {
        // TODO: 调用服务层方法并返回响应
        StudentAnswer result = studentAnswerService.submitAnswer(answer);
        return ResponseEntity.ok(result.getAnswerId());
    }

}
